<template>
    <div class="Info">
        <top/>
        <div class="content">
            <div class="left">
                <p @click="$router.push('/teacher')" >个人中心</p>
                <ul>
                    <li @click="$router.push('/teacher/order')">订单管理</li>
                    <li @click="$router.push('/teacher/orderHistory')">历史订单</li>
                    <li @click="$router.push('/teacher/address')">地址管理</li>
                    <li @click="$router.push('/teacher/updateInfo')">信息修改</li>
                    <li @click="$router.push('/teacher/updatePwd')">密码修改</li>
                    <li @click="$router.push('/')">回到首页</li>
                    <li @click="this.$reLogin()">退出账号</li>
                </ul>
            </div>
            <div class="right">
                <div v-if="$router.currentRoute.fullPath === '/teacher'" class="welcome">
                    <img src="../../../assets/my-lib-index-top.jpg">
                    <p>{{$vals.name}},您好！</p>
                    <ul>
                        <li>未完成订单：{{statistic.todo}}</li>
                        <li>配送中订单：{{statistic.distribute}}</li>
                        <li>借阅次数：{{statistic.finish}}</li>
                    </ul>
                </div>
                <router-view/>
            </div>
        </div>
        <bottom/>
    </div>
</template>

<script>
    export default {
        props: {},
        created() {
            // 如果当前用户名不能为空
            if (this.$vals.username === '')
                this.$router.push('/');
            // 检查是否在登录状态
            this.$axios.get('/user')
                .then(res => {
                    if (res.data.code !== 200)
                        this.$router.push('/');
                });
            // 获取统计信息
            this.$axios.get('/order/teacher-statistic')
                .then(res => {
                    if (res.data.code === 200) {
                        this.statistic = res.data.content;
                    }
                })
        },
        data() {
            return {
                // 未完成、配送中、借阅完成的
                statistic: {},
            }
        },
        methods: {}

    };
</script>
<style lang="scss" scoped>
    @import "Info";
</style>
